package org.liaoxuefeng.study;

import lombok.val;
import org.liaoxuefeng.config.HikariCPConfig;
import org.liaoxuefeng.entity.Student;
import org.testng.annotations.Test;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author: 默苍璃
 * @date: 2022-09-28 16:48
 * JDBC连接池
 */
public class JDBCConnectionPool {

    /**
     * 创建连接
     */
    @Test
    public void test() throws SQLException {
        DataSource dataSource = HikariCPConfig.getConnection();

        Connection connection1 = dataSource.getConnection();
        System.out.println(connection1);
        Connection connection2 = dataSource.getConnection();
        System.out.println(connection2);
        Connection connection3 = dataSource.getConnection();
        System.out.println(connection3);
        Connection connection4 = dataSource.getConnection();
        System.out.println(connection4);
        Connection connection5 = dataSource.getConnection();
        System.out.println(connection5);
        Connection connection6 = dataSource.getConnection();
        System.out.println(connection6);
    }

}
